Replication files for "Evaluating (weighted) dynamic treatment effects
by double machine learning" by Hugo Bodory, Martin Huber, and Lukáš Lafférs
2022-01-16

The files in this archive replicate the results reported in the 
"SIMULATION STUDY" and "EMPIRICAL APPLICATION" sections of the paper.
They also reproduce findings shown in the "ONLINE SUPPLEMENT". 


1. Software used:
-----------------
R 4.1.0 (to replicate Tables 1, 2, 6, 7, and 8, and Figures S1 to S6)
    R packages and version numbers:
    SuperLearner 2.0-28
    e1071 1.7-7 
    glmnet 4.1-2
    ranger 0.12.1
    xgboost 1.4.1.1 
    tictoc 1.0.1
    parallel base
    writexl 1.4.0
    ggplot2 3.3.5
    dplyr 1.0.7
    mvtnorm 1.1-2 
    xtable 1.8-4 
    MASS 7.3-54
    DescTools 0.99.44           
 
Python 3.9.7 (to replicate Tables 3, 4, 5, and S1)
    Python libraries and version numbers:
    pandas 1.3.4
    numpy 1.20.3
    re 2.2.1
    pyreadstat 1.1.4


2. Simulation study:
--------------------
Tables 1 and 2 of the paper indicate R2 statistics and simulation results.
These tables can be reproduced by the R files table1.R and table2.R. 


3. Dataset construction for the empirical application:
------------------------------------------------------
We use the data file data.csv in our empirical application to analyze dynamic 
treatment effects of the Job Corps program. The data can be downloaded from 
the Harvard Dataverse repository at: https://dataverse.harvard.edu/api/access/datafile/5744078

The Python file preparing_data.py constructs the dataset data.csv by 
importing ten SAS data files. The file names are: impact.sas7bdat, 
rand_dat.sas7bdat, jc_tl.sas7bdat, edtrn_tl.sas7bdat, fu12_raw.sas7bdat,
base_raw.sas7bdat, baseline.sas7bdat, key_vars.sas7bdat, other_tl.sas7bdat, 
and empl_tl.sas7bdat. They can be downloaded from the openICPSR repository at: 
https://www.openicpsr.org/openicpsr/project/113269/version/V1/view


4. Empirical application:
-------------------------
The Python file preparing_data.py replicates the descriptive statistics shown 
in Tables 3, 4, and 5 of the paper, as well as in Table S1 of the Online 
Supplement.

Running the R file tables_6_7_figures_S1_to_S6.R reproduces the results of the
effect estimations stated in Tables 6 and 7. In addition, it replicates the 
density plots of the propensity scores displayed in Figures S1 to S6 in the 
Online Supplement.

The findings of the placebo test presented in Table 8 can be obtained by 
running the R code in the file table8.R.
